/**
 * Book路由模块
 */

var express = require('express');
var router = express.Router();

//导入所需控制
const { fetchFromDouban } = require("../controller/fetch")
const book = require("../controller/book");

const auth = require("../controller/auth")

// TODO:增加新的功能，及增加对应路由，控制器以及访问数据库的数据模型

//所有路由都必须执行权限控制的判断
router.all("*",auth.isLogin);

// 定义路由
router.get("/fetch/douban/:isbn",fetchFromDouban);
// 通过isbn查找书籍
router.get("/isbn/:isbn",book.findByIsbn)
//查找书籍
router.get("/search",book.search)
//获取总数
router.get("/count",book.getCount);

router.get("/:id",book.find);

router.get("/",book.findAll);

router.post("/",book.add);

router.put("/:id",book.update);

router.delete("/:id",book.remove);

//定义路由
router.get("/fetch/douban/:isbn",fetchFromDouban)


module.exports = router;